//
//  MoralityTableViewCell.m
//  MXClassroom
//
//  Created by 你个LB on 16/9/9.
//  Copyright © 2016年 你个LB. All rights reserved.
//

#import "MoralityTableViewCell.h"

@implementation MoralityTableViewCell

/** 初始化方法 */
+ (instancetype)cellWithTableView:(UITableView *)tableView{
    static NSString * reuseIdentifier = @"identifier";
    MoralityTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:reuseIdentifier];
    if (cell == nil) {
        // 创建cell
        cell = [[MoralityTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:reuseIdentifier];
    }
    return cell;
}

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        // 头像
        _headImgView = [[UIImageView alloc] initWithFrame:CGRectMake(16, 15, 40, 40)];
        [self.contentView addSubview:_headImgView];
        
        // 法师姓名
        _nameLabel = [[UILabel alloc] initWithFrame:CGRectMake(_headImgView.right + 16, 10, kScreen_width - 3 * 16 - 40 - 80, 20)];
        _nameLabel.textColor = kColor_text_color;
        _nameLabel.font = [UIFont systemFontOfSize:10];
        [self.contentView addSubview:_nameLabel];
        
        // 介绍
        _introductionLabel = [[UILabel alloc] initWithFrame:CGRectMake(_headImgView.right + 16, _nameLabel.bottom + 5, kScreen_width - _headImgView.width - 2 * 16, 25)];
        _introductionLabel.textColor = kColor_introduction_color;
        _introductionLabel.font = [UIFont systemFontOfSize:10];
        _introductionLabel.numberOfLines = 0;
        [self.contentView addSubview:_introductionLabel];
        
        // 关注按钮
        _attentionBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        _attentionBtn.frame = CGRectMake(kScreen_width - 65 - 16, (70 - 18) / 2, 65, 18);
        [_attentionBtn setBackgroundImage:[UIImage imageNamed:@"bg_main_discovery_dade_follow.png"] forState:UIControlStateNormal];
        [_attentionBtn setTitle:@"关注" forState:UIControlStateNormal];
        _attentionBtn.titleLabel.font = [UIFont systemFontOfSize:12];
//        _attentionBtn.titleLabel.textColor = kColor_text_color;
        [_attentionBtn setTitleColor:kColor_text_color forState:UIControlStateNormal];
        [self.contentView addSubview:_attentionBtn];
    }
    return self;
}

- (void)setMorality:(MoralityModel *)morality{
    if (_morality != morality) {
        _morality = morality;
        
        // 为控件设置数据
        _headImgView.image = [UIImage imageNamed:[NSString stringWithFormat:@"%@", morality.headImg]];
        
        _nameLabel.text = morality.name;
        
        _introductionLabel.text = morality.introduction;
    }
}


@end
